<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://a42.vodafone.com/versions/all/v1.0"
    xmlns:tns="http://a42.vodafone.com/versions/all/v1.0"
    elementFormDefault="qualified"
>

    <!-- XML schema 1.0 legacy!!! -->

    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    <!-- Definition of XML representations for shop catalog resources and related DTOs. -->
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

    <!-- Import the common types for A42 resources. -->
    <xs:include schemaLocation="a42.xsd" />

    <!-- Specific link types with defined link relation types. -->
    <xs:complexType name="ContentProvidersLinkType">
        <xs:complexContent>
            <xs:restriction base="tns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/contentProviders" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="ContentProviderLinkType">
        <xs:complexContent>
            <xs:restriction base="tns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/contentProvider" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CategoriesLinkType">
        <xs:complexContent>
            <xs:restriction base="tns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/categories" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CategoryLinkType">
        <xs:complexContent>
            <xs:restriction base="tns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/category" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CatalogItemsLinkType">
        <xs:complexContent>
            <xs:restriction base="tns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/catalogItems" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CatalogItemLinkType">
        <xs:complexContent>
            <xs:restriction base="tns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/catalogItem" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

    <!-- Representation for the service document for this API. -->
    <xs:element name="sc2ServiceDocument">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="contentProvidersRootLink" type="tns:ContentProvidersLinkType" />
                <xs:element name="categoriesRootLink" type="tns:CategoriesLinkType" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

    <!-- Representation for a collection resource that aggregates content provider entities. -->
    <xs:element name="contentProviders" type="tns:ContentProvidersType" />
    <xs:complexType name="ContentProvidersType">
        <xs:complexContent>
            <xs:extension base="tns:PaginatableResourceType">
                <xs:sequence>
                    <!-- The actual collection of resource links. -->
                    <xs:element name="items" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                            <xs:choice>
                                <xs:sequence>
                                    <xs:element name="contentProvider" type="tns:ContentProviderType" minOccurs="0" maxOccurs="unbounded" />
                                </xs:sequence>
                                <xs:sequence>
                                    <xs:element name="link" type="tns:ContentProviderLinkType" minOccurs="0" maxOccurs="unbounded" />
                                </xs:sequence>
                            </xs:choice>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- Representation for a collection resource that aggregates category entities. -->
    <xs:element name="categories" type="tns:CategoriesType" />
    <xs:complexType name="CategoriesType">
        <xs:complexContent>
            <xs:extension base="tns:PaginatableResourceType">
                <xs:sequence>
                    <!-- The actual collection of resource links. -->
                    <xs:element name="items" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                            <xs:choice>
                                <xs:sequence>
                                    <xs:element name="category" type="tns:CategoryType" minOccurs="0" maxOccurs="unbounded" />
                                </xs:sequence>
                                <xs:sequence>
                                    <xs:element name="link" type="tns:CategoryLinkType" minOccurs="0" maxOccurs="unbounded" />
                                </xs:sequence>
                            </xs:choice>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- Representation for a collection resource that aggregates catalog item entities. -->
    <xs:element name="catalogItems" type="tns:CatalogItemsType" />
    <xs:complexType name="CatalogItemsType">
        <xs:complexContent>
            <xs:extension base="tns:PaginatableResourceType">
                <xs:sequence>
                    <!-- The actual collection of resource links. -->
                    <xs:element name="items" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                            <xs:choice>
                                <xs:sequence>
                                    <xs:element name="catalogItem" type="tns:CatalogItemType" minOccurs="0" maxOccurs="unbounded" />
                                </xs:sequence>
                                <xs:sequence>
                                    <xs:element name="link" type="tns:CatalogItemLinkType" minOccurs="0" maxOccurs="unbounded" />
                                </xs:sequence>
                            </xs:choice>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

    <!-- Representation for a content provider resource. -->
    <xs:element name="contentProvider" type="tns:ContentProviderType" />
    <xs:complexType name="ContentProviderType">
        <xs:complexContent>
            <xs:extension base="tns:ResourceType">
                <xs:sequence>
                    <!-- The link to the catalog items aggregated by this content provider. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="catalogItemsLink" type="tns:CatalogItemsLinkType" />
                        <xs:element name="catalogItems" type="tns:CatalogItemsType" />
                    </xs:choice>
                    <!-- The name of the content provider. -->
                    <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- An external ID, if applicable. To be used for search queries. -->
                    <xs:element name="partnerId" type="xs:string" minOccurs="0" maxOccurs="1" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- Representation for a category resource. -->
    <xs:element name="category" type="tns:CategoryType" />
    <xs:complexType name="CategoryType">
        <xs:complexContent>
            <xs:extension base="tns:ResourceType">
                <xs:sequence>
                    <!-- Link to the parent item, will not appear in case it is a top-level category. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="parentCategoryLink" type="tns:CategoryLinkType" />
                        <xs:element name="parentCategory" type="tns:CategoryType" />
                    </xs:choice>
                    <!-- Link to sub-categories, if applicable. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="subCategoriesLink" type="tns:CategoriesLinkType" />
                        <xs:element name="subCategories" type="tns:CategoriesType" />
                    </xs:choice>
                    <!-- Link to catalog items within this category. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="catalogItemsLink" type="tns:CatalogItemsLinkType" />
                        <xs:element name="catalogItems" type="tns:CatalogItemsType" />
                    </xs:choice>
                    <!-- The name of the category. -->
                    <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- An external ID, if applicable. To be used for search queries. -->
                    <xs:element name="externalId" type="xs:string" minOccurs="0" maxOccurs="1" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- Representation for a catalog item resource. -->
    <xs:element name="catalogItem" type="tns:CatalogItemType" />
    <xs:complexType name="CatalogItemType">
        <xs:complexContent>
            <xs:extension base="tns:ResourceType">
                <xs:sequence>
                    <!-- The content provider of the item. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="contentProviderLink" type="tns:ContentProviderLinkType" />
                        <xs:element name="contentProvider" type="tns:ContentProviderType" />
                    </xs:choice>
                    <!-- The category of the item. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="categoryLink" type="tns:CategoryLinkType" />
                        <xs:element name="category" type="tns:CategoryType" />
                    </xs:choice>
                    <!-- Link to the parent item, will not appear in case it is a top-level item. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="parentItemLink" type="tns:CatalogItemLinkType" />
                        <xs:element name="parentItem" type="tns:CatalogItemType" />
                    </xs:choice>
                    <!-- Link to sub-items, if applicable. -->
                    <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element name="subItemsLink" type="tns:CatalogItemsLinkType" />
                        <xs:element name="subItems" type="tns:CatalogItemsType" />
                    </xs:choice>
                    <!-- The name of the item. -->
                    <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- A description for the item. -->
                    <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- An external ID, if applicable. To be used for search queries. -->
                    <xs:element name="externalId" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- Type of the product, e.g. app, game, virtual good, music, etc. -->
                    <xs:element name="type" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- Flag that sets a catalog item active or inactive. It can also decouple creation from activation. -->
                    <xs:element name="isActive" type="xs:boolean" minOccurs="0" maxOccurs="1" />
                    <!-- When was (will) this item (be) released. In addition to "createdAt", can decouple creation from activation. -->
                    <xs:element name="releasedAt" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
                    <!-- Provides information about a certain age that needs to be proven to access a product. -->
                    <xs:element name="grade" type="xs:unsignedByte" minOccurs="0" maxOccurs="1" />
                    <!-- Even more details as a collection of (key, value) pairs. -->
                    <xs:element name="details" type="tns:KeyValueCollectionType" minOccurs="0" maxOccurs="1" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

</xs:schema>
